package com.halopay.controler;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.halopay.common.utils.R;
import me.chanjar.weixin.common.error.WxErrorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mingpingqiang on 2018/12/4/11:34
 * Created by mingpingqiang on 2018/12/4/11:34
 */
@RestController
@RequestMapping("/api/wx")
public class WxMaUserController {
    @Autowired
    private WxMaService wxMaService;
    private static final Logger log = LoggerFactory.getLogger(WxMaUserController.class);
    @RequestMapping("/getSessionInfo")
    public R getSessionInfo(String code) throws WxErrorException {
        WxMaJscode2SessionResult result = wxMaService.getUserService().getSessionInfo(code);
       return R.ok().put("wxUserInfo",result);
    }
}
